package edu.bbte;

public class Test {
	public static void main(String [] args) {
		/*MatrixCube a;
		a = new MatrixCube(2);
		a.setBound(9);
		try {
			a.readCubeFromFile("files/be.txt");
		} catch (MatrixException e) {
			e.printStackTrace();
		}
		a.printAll();
		a.printCubeToFile("files/ki.txt");
		if (a.shiftCubeBack()) {System.out.println("OK");}
		
		a.printAll();
			*/
		/*
		MatrixCube m, n;
		m = new MatrixCube(3);
		n = new MatrixCube(3);
		m.setCube(p[0]);
		n.setCube(p[1]);
		m.printAll();
		System.out.println("A 2. matrix: -----------------------");
		n.shiftCubeUp();
		n.printAll();
		if (!m.sumCube(n)) 
			System.out.println("A fenebe bele");
		else
			System.out.println("Yeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
		m.printAll();
		m.differenceCube(n);
		m.printAll();
		*/
		
		/*
		try {
			MatrixCube b;
			b = a.shiftCubeForward();
			b.setBound(9);
			b.printAll();
			b = b.shiftCubeForward();
			b.printAll();
			b = b.shiftCubeForward();
			b.printAll();
			b = b.shiftCubeRight();
			b.printAll();
			b.printAll();
			b = b.rotateCubeX();
			b.printAll();
			MatrixCube [] c = a.listOfCubeRotations();
			boolean jo = true;
			for (int i = 0; i<23; ++i)
				for (int j=i+1; j<24; ++j)
					if (c[i].equalsCube(c[j]))
						jo = false;
			if (!jo)
				System.out.println("Nem jo a forgatas!");
			else
				System.out.println("Joo te a forgatas (elvileg)!");
		} catch (MatrixException e) {
			e.printStackTrace();
		}
		//teszteles
		MatrixCube [] l = new MatrixCube[7];
		int i;
		for (i=0; i<7; i++) {
			l[i] = new MatrixCube(3);
			try {
				l[i].readCubeFromFile("files/1."+(i+1)+".txt");
			} catch (MatrixException e) {
				e.printStackTrace();
			}
		}
		
		
		MatrixCube o;
		try {
			o = l[0].sumCube(l[1]);
			for (i=2; i<7; i++)
				o = o.sumCube(l[i]);
			o.printCube();
		} catch (MatrixException e) {
			e.printStackTrace();
		}	*/		
		
		
		MatrixCube c;
		c = new MatrixCube(3);
		c.setBound(9);
		try {
			c.readCubeFromFile("files/examples/2/2.1.txt");
		} catch (MatrixException e) {
			e.printStackTrace();
		}
		MatrixCube [] shifts = c.listOfCubeRotations();//c.listOfCubeShifts(2, 2, 2, 2, 2, 2);
		System.out.println("Az osszes eltolas: ");
		int n = shifts.length;
		for (int i=0; i<n; ++i) {
			//shifts[i].printAll();
			//System.out.println("Az "+i+". forgatas:");
		}
			
		Matrix3D [] p = new Matrix3D[6];
		for (int i=1; i<7; ++i) {
			p[i-1] = new Matrix3D(3);
			try {
				String s = "files/examples/2/2." + i + ".txt";
				p[i-1].readMatrixFromFile(s);
			} catch (MatrixException e) {
				e.printStackTrace();
			}
		}
		
		SolveCube2 solv = new SolveCube2(p,6);
		long stime=System.currentTimeMillis();
			solv.solve2();
		long time=System.currentTimeMillis()-stime;
		System.out.println("Build time:"+(time/1000F)+" sec");
		Matrix3D solution[] = new Matrix3D[6];
		solution = solv.getSolutions3D();
		for (int i=0; i<6; ++i) {
			System.out.println("Az "+i+". matrix:");
			solution[i].printMatrix();
		}
	}
	
}
